﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.MobileControls;
using System.Collections;

public partial class ObjectList_ObjectListItemCommandsExample : System.Web.UI.MobileControls.MobilePage
{
 
    private void Page_Load(Object sender, EventArgs e)
    {
        this.ObjectList1.ItemCommand +=
             new ObjectListCommandEventHandler(this.Team_OnItemCommand);
        if (!IsPostBack)
        {
            ArrayList array = new ArrayList();
            array.Add(new TeamStats("Dunes", 1, 38, 24, 8, 6, 80,
                                            "Quarter Finals", ""));
            array.Add(new TeamStats("Phoenix", 2, 38, 20, 10, 8, 70,
                                            "Quarter Finals", ""));
            array.Add(new TeamStats("Eagles", 3, 38, 20, 9, 9, 69,
                                            "", "Winners"));
            array.Add(new TeamStats("Zodiac", 4, 38, 20, 8, 10, 68,
                                            "Semi Finals", ""));

            ObjectList1.DataSource = array;
            ObjectList1.LabelField = "TeamName";
            ObjectList1.DataBind();
        }
    }

    private void Team_OnItemCommand(Object sender, ObjectListCommandEventArgs e)
    {
        Label1.Text = "Did Not Compete"; //Default
        this.ActiveForm = Form2;

        if (e.CommandName == "ChampsCup")
        {
            // Set the label to the Champions Cup result.
            if (e.ListItem["ChampionsCup"] != "")
                Label1.Text = "Champions Cup: " +
                    e.ListItem["ChampionsCup"];
        }
        else if (e.CommandName == "InterCityCup")
        {
            // Set the label to the Inter-City Cup result.
            if (e.ListItem["InterCup"] != "")
                Label1.Text = " Inter-City Cup: " +
                    e.ListItem["InterCup"];
        }
    }
}